<?php
/** @var Payment $payment */
use Overtrue\Wechat\Payment;

?>

<div style="">

</div>










<script>
    var WXPayment = function() {
        if( typeof   === 'undefined' ) {
            alert('请在微信在打开页面！');
            return false;
        }
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', <?= $payment->getConfig(); ?>, function(res) {
                switch(res.err_msg) {
                    case 'get_brand_wcpay_request:cancel':
                        alert('用户取消支付！');
                        break;
                    case 'get_brand_wcpay_request:fail':
                        alert('支付失败！（'+res.err_desc+'）');
                        break;
                    case 'get_brand_wcpay_request:ok':
                        alert('支付成功！');
                        break;
                    default:
                        alert(JSON.stringify(res));
                        break;
                }
            });
    }
</script>


<button type="button" onclick="WXPayment()">支付 ￥<?php echo ($order->total_fee / 100); ?> 元</button>
